package br.unifor.cadeventos.manager;

import br.unifor.cadeventos.business.UsuarioBusiness;
import br.unifor.cadeventos.exceptions.BusinessException;
import br.unifor.cadeventos.internacionalizacao.Messagens;
import br.unifor.cadeventos.utils.DesktopContext;

public class UsuarioManager {
	
	private static UsuarioBusiness usuarioBusiness = new UsuarioBusiness();
	
	public String logar(String email, String senha){
		try {
			DesktopContext.setUsuarioLogado(usuarioBusiness.login(email, senha)); 
			if(DesktopContext.getUsuarioLogado() != null){
				return Messagens.WELLCOME + " " +DesktopContext.getUsuarioLogado().getEmail();
			} else {
				return Messagens.MSG_EXRG4;
			}
		} catch (BusinessException e) {
			return e.getMessage();
		}
		
	}
}
